package org.goodev.arch;

import android.app.Application;

import org.goodev.arch.api.GithubService;
import org.goodev.arch.retrofit.LiveDataCallAdapterFactory;

import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;


public class App extends Application {

    GithubService mService;
    @Override
    public void onCreate() {
        super.onCreate();
        mService = genGithubService();
    }

    public GithubService getGithubService() {
        return mService;
    }

    private GithubService genGithubService() {
        return new Retrofit.Builder()
                .baseUrl("https://api.github.com/")
                .addConverterFactory(GsonConverterFactory.create())
                .addCallAdapterFactory(new LiveDataCallAdapterFactory())
                .build()
                .create(GithubService.class);
    }
}
